package oop.ex2.tokenizer;

import oop.ex2.expression.ExpressionNode;
import oop.ex2.expression.VariableNode;
import oop.ex2.expression.VariableTable;

/**
 * This analyzer searches for a variable. It stores a variable table that it passes to the
 * variable node.
 * @author daniel_i_l
 *
 */
public class VariableAnalyzer extends TokenAnalyzer {
	public static final String VARIABLE_PATTERN = "@[a-z][a-z0-9]*[0-9]";
	private VariableTable _variableTable;
	
	/**
	 * Create a variable analyzer using a specified variable table.
	 * @param variableTable
	 */
	public VariableAnalyzer(VariableTable variableTable) {
		super(VARIABLE_PATTERN);
		_variableTable = variableTable;
	}

	@Override
	public ExpressionNode getExpressionNode() {
		return new VariableNode(_matchedString, _variableTable);
	}

}
